home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Especial Multimedia
/
Especial Multimedia.iso
/
Multimed
/
Presenta
/
EV2FREE.ZIP
/
EFREE3.ICZ
/
EDLLDRV.BAS
< prev
next >
Wrap
BASIC Source File
|
1995-03-06
|
10KB
|
321 lines
'Declare Function Play% Lib "mhen200.vbx" (ByVal Lin$)
'Declare Sub PlayStop Lib "mhen200.vbx" ()
'Declare Function MhASCIIMid% Lib "Muscle.vbx" (a$, ByVal Position%)
'Declare Function MhHexStrInt$ Lib "Muscle.vbx" (ByVal Fmt%, IntVal%)
'Declare Function MhHexValInt% Lib "Muscle.vbx" (Hexa$)
'Declare Function MhReplaceChar$ Lib "Muscle.vbx" (Lin$, ByVal OldChar%, ByVal NewChar%)
'Declare Function MhSpecToken$ Lib "Muscle.vbx" (ByVal Which%, Spec$)
'Declare Function MhWinDir$ Lib "Muscle.vbx" ()
'Declare Function cvc@ Lib "Muscle.vbx" (ByVal Lin$)
'Declare Function cvd# Lib "Muscle.vbx" (ByVal Lin$)
'Declare Function cvi% Lib "Muscle.vbx" (ByVal Lin$)
'Declare Function cvl& Lib "Muscle.vbx" (ByVal Lin$)
'Declare Function cvs! Lib "Muscle.vbx" (ByVal Lin$)
'Declare Function mkc$ Lib "Muscle.vbx" (a@)
'Declare Function mkd$ Lib "Muscle.vbx" (a#)
'Declare Function mki$ Lib "Muscle.vbx" (ByVal a%)
'Declare Function mkl$ Lib "Muscle.vbx" (ByVal l&)
'Declare Function MKS$ Lib "Muscle.vbx" (a!)
Declare Function GetDriveType% Lib "Kernel" (ByVal nDrive As Integer)
Declare Function GetKeyboardType% Lib "Keyboard" (ByVal nTypeFlag As Integer)
Declare Function GetSysColor& Lib "User" (ByVal nIndex As Integer)
Declare Function SetParent% Lib "User" (ByVal hWndChild%, ByVal hWndNewParent%)
'***********************************
' include this module with your Everest external program
' it provides the communications between Everest and your program
' your program acts as a DDE server
' Everest is the DDE destination
'***********************************
' put type declarations here (if any)
Type type242
chr242 As String * 1
i As Integer
End Type
Type type242s
s As String * 3
End Type
Type type243
chr243 As String * 1
l As Long
End Type
Type type243s
s As String * 5
End Type
Type type244
chr244 As String * 1
s As Single
End Type
Type type244s
s As String * 5
End Type
Type type245
chr245 As String * 1
d As Double
End Type
Type type245s
s As String * 9
End Type
Type type246
chr246 As String * 1
c As Currency
End Type
Type type246s
s As String * 9
End Type
'*************************************
' put constant declarations here
Const mainpath$ = "C:\"
Const yes = -1
Const chr124$ = "|"
'**************************************
' allocate local typed vars here
' *************************************
' declare global variables here
Global zr%
Global t242 As type242, t242s As type242s
Global t243 As type243, t243s As type243s
Global t244 As type244, t244s As type244s
Global t245 As type245, t245s As type245s
Global t246 As type246, t246s As type246s
Sub dllmgr (op%, em$)
' op% = 1: process incoming em$ execute string
Static makechange%
' init vars
chr0$ = Chr$(0)
' perform operation indicated by op%
If op% = 1 Then
' the following block of code puts chr 0 at proper places in em$
' (necessary because DDE cannot transmit chr 0)
u& = Val(Left$(em$, 5)) ' get chr0$ sub technique (in header)
If u& < 0 Then ' < 0 means quick sub code
'subchar% = Abs(u&) ' char that means chr 0
'em$ = MhReplaceChar$(em$, subchar%, 0) ' replace sub char with chr 0
subchr$ = Chr$(Abs(u&))
pt% = 0
Do
pt% = InStr(pt% + 1, em$, subchr$): If pt% = 0 Then Exit Do
Mid$(em$, pt%) = chr0$
Loop
Else ' else, sub list technique
zl$ = Mid$(em$, 6 + u&) ' header + em$ to start of zl$
Do ' loop through zero list
make0% = Val(zl$): If make0% <= 0 Then Exit Do
Mid$(em$, make0%) = chr0$
pt% = InStr(zl$, chr124$): If pt% = 0 Then Exit Do
zl$ = Mid$(zl$, pt% + 1)
Loop
End If
' next, uncompress the incoming message
' and parse it into parameters (up to 20)
em$ = fnExtx(em$, 6&) ' expand incoming message
ReDim p(20)
x% = 1: empt& = 1
Do While empt& <= Len(em$)
p(x%) = fnExtx(em$, empt&)
'If IsNumeric(p(x%)) Then p(x%) = Val(p(x%))
x% = x% + 1
Loop
' perform DLL or special routine call
' put result into vary
' (add new calls as additional CASEs here;
' anything goes, does not have to be API call;
' any programming you wish can go here)
Select Case LCase$(p(1)) ' p(1) has routine name
Case "getdrivetype"
i% = p(2)
vary = GetDriveType%(i%)
Case "getkeyboardtype"
i% = p(2)
vary = GetKeyboardType%(i%)
Case "getsyscolor"
i% = p(2)
vary = GetSysColor&(i%)
Case "**shutdown**" ' special message to end program
shutdown% = yes
Case Else
vary = "No such DLL routine defined: " & p(1)
End Select
' next, prepare reply to Everest
em$ = Space$(6) + fnCompX$(vary) ' 6 spaces = room for header
' now substitute for chr$(0) due to DDE inability to transmit chr$(0)
For subchar% = 254 To 1 Step -1 ' look for 0 substitute candidate
If InStr(em$, Chr$(subchar%)) = 0 Then Exit For ' this one not elsewhere in string
Next
If subchar% Then ' sub avail
'em$ = MhReplaceChar$(em$, 0, subchar%) ' quickest, but requires MicroHelp's Muscle
subchr$ = Chr$(subchar%)
pt% = 0
Do
pt% = InStr(pt% + 1, em$, chr0$): If pt% = 0 Then Exit Do
Mid$(em$, pt%) = subchr$
Loop
Mid$(em$, 1, 5) = CStr(-subchar%) + " " ' put sub char at start of em$
Else ' no sub, must create list (slow!)
Mid$(em$, 1, 5) = CStr(Len(em$) - 6) + " " ' save original em$ len
pt% = 0
Do ' loop & build zero list
pt% = InStr(pt% + 1, em$, chr0$)
zl$ = zl$ + CStr(pt%) + chr124$
Mid$(em$, pt%) = "*" ' anything but chr$(0)
Loop
em$ = em$ + zl$ ' put zero list on end
End If
If makechange% >= 255 Then makechange% = 0 ' assures change event will fire in Everest
makechange% = makechange% + 1
Mid$(em$, 6) = Chr$(makechange%)
' send reply via Textbox (Everest is waiting for this)
dlldde.Data.Text = em$
' the following applies during an Everest shutdown
' (end this program too)
If shutdown% Then
DoEvents
End
End If
End If
End Sub
Function fnCompX$ (prop As Variant)
' "compress" incoming prop into a string
' this is the opposite of fnExtx
typ% = VarType(prop)
If typ% < 2 Then ' 240=empty, 241=Null
fnCompX$ = Chr$(240 + typ%)
ElseIf typ% = 8 Then ' string
chars& = Len(prop)
Select Case chars&
Case 0& ' null string
fnCompX$ = Chr$(250)
Case Is < 240& ' short string
fnCompX$ = Chr$(chars&) + prop
Case Is < 32000 ' medium string, use hex
fnCompX$ = Chr$(248) + Right$("0000" + Hex$(chars&), 4) & prop
Case Else
fnCompX$ = Chr$(248) + Right$("0000" + Hex$(32000), 4) & Left$(prop, 32000)
zr% = -277
End Select
ElseIf typ% < 7 And prop = 0 Then ' numeric 0
fnCompX$ = Chr$(251)
ElseIf typ% = 2 Then ' int (short)
t242.i = prop: LSet t242s = t242
fnCompX$ = t242s.s
ElseIf typ% = 3 Then ' int (long)
t243.l = prop: LSet t243s = t243
fnCompX$ = t243s.s
ElseIf typ% = 4 Then ' single
t244.s = prop: LSet t244s = t244
fnCompX$ = t244s.s
ElseIf typ% = 5 Then ' double
t245.d = prop: LSet t245s = t245
fnCompX$ = t245s.s
ElseIf typ% = 6 Then ' currency
t246.c = prop: LSet t246s = t246
fnCompX$ = t246s.s
Else ' date (8 bytes) or newtype
fnCompX$ = Chr$(240 + typ%) & prop
End If
End Function
Function fnExtx (s$, pt&)
' "extend" s$ (uncompress) and return as variant
' this is the opposite of fnCompx
On Error GoTo fnExtxerr
typ% = Asc(Mid$(s$, pt&, 1)) ': pt& = pt& + 1
If typ% < 240 Then ' short string
pt& = pt& + 1
fnExtx = Mid(s$, pt&, typ%)
pt& = pt& + typ%
ElseIf typ% = 240 Then ' empty
pt& = pt& + 1
fnExtx = Empty
ElseIf typ% = 250 Then ' null
pt& = pt& + 1
fnExtx = ""
ElseIf typ% = 251 Then ' 0
pt& = pt& + 1
fnExtx = 0
ElseIf typ% = 242 Then ' int
t242s.s = Mid$(s$, pt&, 3): LSet t242 = t242s
fnExtx = t242.i
pt& = pt& + 3
ElseIf typ% = 243 Then ' long
t243s.s = Mid$(s$, pt&, 5): LSet t243 = t243s
fnExtx = t243.l
pt& = pt& + 5
ElseIf typ% = 244 Then ' single
t244s.s = Mid$(s$, pt&, 5): LSet t244 = t244s
fnExtx = t244.s
pt& = pt& + 5
ElseIf typ% = 245 Then ' double
t245s.s = Mid$(s$, pt&, 9): LSet t245 = t245s
fnExtx = t245.d
pt& = pt& + 9
ElseIf typ% = 248 Then ' long string
pt& = pt& + 1
fnExtx = Mid(s$, pt& + 4, Val("&H" + Mid$(s$, pt&, 4)))
pt& = pt& + typ% + 4
ElseIf typ% = 249 Then ' very long string
pt& = pt& + 1
chars& = CLng(Mid$(s$, pt&, 5))
fnExtx = Mid(s$, pt& + 5, chars&)
pt& = pt& + chars& + 5
ElseIf typ% = 246 Then ' currency
t246s.s = Mid$(s$, pt&, 9): LSet t246 = t246s
fnExtx = t246.c
pt& = pt& + 9
ElseIf typ% = 247 Then ' date
pt& = pt& + 1
fnExtx = Mid(s$, pt&, 8)
pt& = pt& + 8
End If
fnExtxbot:
Exit Function
fnExtxerr:
fnExtx = ""
Resume fnExtxbot
End Function